package imagekeeper.data;

import java.sql.CallableStatement;
import java.sql.ResultSet;
import java.sql.SQLException;


abstract class SqlStatement {
    protected CallableStatement statement;
    
    public ResultSet executeQuery() throws SQLException {
        return statement.executeQuery();
    }
    
    public int executeUpdate() throws SQLException {
        return statement.executeUpdate();
    }
    
    public CallableStatement getInnerStatement() {
        return statement;
    }
    
    public void clearParameters() throws SQLException {
        statement.clearParameters();
    }
    
    public void close() {
        try {
            statement.close();
        }
        catch (SQLException ex) { }
    }
    
    protected void setParameter(String paramName, Object param, int sqlDataType) throws SQLException {
        if (param != null)
            statement.setObject(paramName, param, sqlDataType);
        else
            statement.setNull(paramName, sqlDataType);
    }
}
